import React from 'react';
import  '../../../../public/css/delevlop.css';
import { inject, observer } from 'mobx-react';

@inject('delevlop')
@observer
export default class SaftyDesc extends React.Component {
    componentDidMount(){
        this.props.delevlop.getSafetyIntro();
    }
    render(){
        const {safetyInfo}=this.props.delevlop;
        const chnNumChar = ['零','一','二','三','四','五','六','七','八','九'];
		const chnUnitSection = ['','万','亿','万亿','亿亿'];
		const chnUnitChar = ['','十','百','千'];
// 节内转换算法
function SectionToChinese(section){
    var strIns = '', chnStr = '';
    var unitPos = 0;
    var zero = true;
    while(section > 0){
        var v = section % 10;
        if(v === 0){
            if(!zero){
                zero = true;
                chnStr = chnNumChar[v] + chnStr;
              }
        }else{
              zero = false;
              strIns = chnNumChar[v];
              strIns += chnUnitChar[unitPos];
              chnStr = strIns + chnStr;
        }
        unitPos++;
        section = Math.floor(section / 10);
    }
    return chnStr;
}
// 转换算法主函数
function NumberToChinese(num){
    var unitPos = 0;
    var strIns = '', chnStr = '';
    var needZero = false;

    if(num === 0){
        return chnNumChar[0];
    }
    while(num > 0){
        var section = num % 10000;
        if(needZero){
            chnStr = chnNumChar[0] + chnStr;
        }
        strIns = SectionToChinese(section);
        strIns += (section !== 0) ? chnUnitSection[unitPos] : chnUnitSection[0];
        chnStr = strIns + chnStr;
        needZero = (section < 1000) && (section > 0);
        num = Math.floor(num / 10000);
        unitPos++;
    }
    return chnStr;
}
        return (
            <div style={{ 'height': '100%' }} className="p20 bgstyle">
                <div>
                    {
                        safetyInfo.map(function (item, index) {
                            return (<div key={index}>
                                <h3 className="pt-10">{NumberToChinese(parseInt(index + 1)) + ' 、' + item.title}</h3>
                                {
                                    item.step.map(function (item1, index1) {
                                        return (<h6 key={index1} className="fontWL pt-10">{'（' + parseInt(index1 + 1) + '）' + item1}</h6>)
                                    }.bind(this))
                                }
                                <br />
                            </div>)
                        }.bind(this))
                    }
                </div>
            </div>
        )
    }
}